<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
    <script src=" https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<script>
    $(document).ready(function () {
        isok=false;
        $("#user").blur(function () {
            var a=$(this).val();
            var b=$("#checkuser")
            if(a===""){
                b.css("color","red");
                b.text("用户名不能为空！");
            }else{
                b.text("");
                isok=true;
            }
        });

        $("#password").blur(function () {
           var a=$(this).val();
           var b=$("#passwordcheck");
           if(a===""){
           b.css("color","red");
           b.text("密码不能为空!");
           }else{
               b.text("");
               isok=true;
           }
        });

        $("#btn").click(function () {
           if(isok){
               var user=$("#user").val(),
                   psw=$("#password").val();
               for(var i=0;i<localStorage.length;i++){
                   var getKey=localStorage.key(i);
                   if(getKey.substring(0,6)==="userID"){
                       var str=localStorage.getItem(getKey);
                       var data=JSON.parse(str);
                       if(user===data.user&&psw===data.password) {
                           $(this).attr("href","logIn_success.html");
                           return;
                       }
                   }
               }
               $(this).attr("href","logIn_fail.html");
           } else{
               $(this).attr("href","logIn_fail.html");
           }
        });
    });

</script>
<body>
<div class="weui-cells">
    <div class="weui-cell">
        <div class="weui-cell__hd"><img src="form_logo.jpg" style="width: 80px;height: 80px"></div>
        <div class="weui-cell__bd">
            <p>用户登录</p>
        </div>
    </div>
</div>
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="text" id="user" placeholder="请输入用户名">
        </div>
        <span id="checkuser"></span>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">密码</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="password" id="password" placeholder="请输入密码">
        </div>
        <span id="passwordcheck"></span>
    </div>
</div>

<a class="weui-btn weui-btn_primary" id="btn">登录</a>


<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>
</body>
</html>